   // "crypto-js": "^4.2.0",
   import CryptoJS from 'crypto-js';

   // 图片压缩
   export const compressImgNew = (file) => {
     return new Promise(resolve => {
       const reader = new FileReader()
       const image = new Image()
       image.onload = (imageEvent) => {
         const canvas = document.createElement('canvas') // 创建画布
         const context = canvas.getContext('2d')         // 画布为2d
         const width = image.width / 1.05        // 图片宽度 / 压缩比例
         const height = image.height / 1.05        // 图片高度 / 压缩比例
         canvas.width = width                            // 画布宽度
         canvas.height = height                          // 画布宽度
         context.clearRect(0, 0, width, height)
         context.drawImage(image, 0, 0, width, height)
         const dataUrl = canvas.toDataURL(file.type)     //图片转路径
         const blobData = dataURLtoBlob(dataUrl, file.type) //图片转二进制
         resolve(blobData)
       }
       reader.onload = e => { image.src = e.target.result }
       reader.readAsDataURL(file)
     })
   };
   
   //图片转二进制
   function dataURLtoBlob(dataURL, type) {
     var binary = atob(dataURL.split(',')[1])
     var array = []
     for (var i = 0; i < binary.length; i++) {
       array.push(binary.charCodeAt(i))
     }
     return new Blob([new Uint8Array(array)], { type: type })
   }
   
   
   // 登录加密
   export function encrypt(data) {
     let key = MD5(process.env.VUE_APP_BASE_KEY)
     // key = MD5('wu-jie-de-you-xi-dev')
     var x = 0
     var len = data.length
     var l = data.length
     var char = ''
     var str = ''
     for (var i = 0; i < len; i++) {
       if (x === l) {
         x = 0
       }
       char += key.charAt(x)
       x++
     }
     for (var j = 0; j < len; j++) {
       str += String.fromCharCode(data.charCodeAt(j) + (char.charCodeAt(j) % 256))
     }
     return btoa(str)
   }
   
   function MD5(data) {
     const hashedPassword = CryptoJS.MD5(data).toString()
     return hashedPassword
   }
   
   
   
   